using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Commerce.Common;

namespace CategoryProductPicker
{
    public partial class CategoryPicker : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
    {
        public string categoryId;

        protected void Page_Load(object sender, EventArgs e)
        {
            Commerce.Common.CategoryCollection categories = null;

            categories = new CategoryCollection().Load();

            foreach (Category thisCat in categories)
            {
                ListItem item = new ListItem();
                item.Text = thisCat.CategoryName;
                item.Value = thisCat.CategoryID.ToString();
                categoryDDL.Items.Add(item);
            }
        }

        protected void categoryDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            categoryId = categoryDDL.SelectedValue.ToString();
        }

        #region IUsercontrolDataEditor Members

        public object value
        {
            get
            {
                return categoryId;
            }
            set
            {
                categoryId = value.ToString();
            }
        }

        #endregion

    }
}